<?php
defined('_JEXEC') or die;
jimport('joomla.application.component.view');

class SanphamViewPosts extends JView {
	
	protected $form;
	protected $pagination;
	
	public function display()
	{
		$task = JRequest::getVar('task');		
		switch ($task){
			case 'add':
			case 'edit':
				$form = $this->get('Form');
				$this->addToolbar();
				$this->setLayout('edit');
				$this->assignRef('form', $form);
				break;
			default:
				$this->viewGrid();
				$this->viewToolbar();
		}
		
		parent::display();
	}
	/* protected function viewForm(){
		//lấy về đối tượng SanphamModelPosts
		$model = $this->getModel();
	
		//tạo ra đối tượng Formm từ tập tin xml mới tạo xong
		$form = $model->getForm();
	
		//đẩy đối tượng đó qua layout để hiển thị
		$this->assignRef('form', $form);
	} */
	
	protected function addToolbar()
	{
		JToolBarHelper::title('Com Sanpham: Edit Post');
		JToolBarHelper::apply();
		JToolBarHelper::save();
		JToolBarHelper::save2new();
		JToolBarHelper::cancel();
		JToolBarHelper::divider();
		JToolBarHelper::help();		
	}
	protected function viewToolbar()
	{
		// assuming you have other toolbar buttons ...
		JFactory::getDocument()->addStyleSheet('components/com_sanpham/asset/css/buttons.css');
		JToolBarHelper::title( 'Com Sanpham: Post');
		JToolBarHelper::addNew();
		JToolBarHelper::editList();
		JToolBarHelper::divider();
		JToolBarHelper::publishList();
		JToolBarHelper::unpublishList();
		JToolBarHelper::custom('important','important','important','important');
		JToolBarHelper::divider();
		JToolBarHelper::archiveList();
		JToolBarHelper::checkin();
		JToolBarHelper::trash();
		JToolBarHelper::divider();
		JToolBarHelper::preferences('com_sanpham');
		JToolBarHelper::divider();
		JToolBarHelper::help('Sanpham_Posts_Manager');
	}
	protected function viewGrid()
	{
		$this->pagination 		= $this->get('Pagination');
		$state 					= $this->get('State');
		
		$this->filter_order_Dir = $state->get('filter_order_Dir');
		$this->filter_order 	= $state->get('filter_order');
		
		$filter_search 			=& $state->get('filter_search');
		$this->assignRef('filter_search',$filter_search );
		
		$data =& $this->get('Data');
		$this->assignRef('data',$data );
	}
}